package com.jmz.apt.api.service.tpl;

import com.jmz.apt.api.dao.TygpGroupDao;
import com.jmz.apt.api.entity.dbEntity.JmzAdminUser;
import com.jmz.apt.api.entity.dbEntity.TimeTygpGroup;
import com.jmz.apt.api.entity.dbEntity.TimeTygpGroupItems;
import com.jmz.apt.api.message.request.Condition;
import com.jmz.apt.api.message.request.Query;
import com.jmz.apt.api.message.request.RequestMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TygpGroup {

    @Autowired
    TygpGroupDao tygpGroupDao;

    public List<TimeTygpGroup> findAllTimeTplGroups(RequestMessage requestMessage) throws DataAccessException {
        List<Condition> condition = requestMessage.getMessage().getBody().getQuery().getCondition();
        Query query = requestMessage.getMessage().getBody().getQuery();
        List<TimeTygpGroup> timeTygpGroups = tygpGroupDao.findGroups("*",condition,query);
        return timeTygpGroups;
    }

    @Transactional
    public  void  saveGroup(TimeTygpGroup timeTygpGroup) throws  DataAccessException{
          tygpGroupDao.saveGroup(timeTygpGroup);
          List<TimeTygpGroupItems> ttgi = timeTygpGroup.getTtgItems();
          if(!ttgi.isEmpty() && ttgi != null){
              
          }

    }



}
